<meta charset="UTF-8"/>
//任务2：简易计算器制作（表格布局：参考自己的手机计算器，满足基本加减乘除运算即可）；<hr/>
<table border="1">
<tr><td colspan="3"><input style="width:100.5" id="result"/></td><td><button onclick="Ac()" style="width:100%">Ac<tton></td></tr>
<tr>
<td><button onclick="s7()" >7<tton></td><td><button onclick="s8()">8<tton></td><td><button onclick="s9()">9<tton></td><td><button onclick="s10()">/<tton></td>
</tr>
<tr>
<td><button onclick="s4()">4<tton></td><td><button onclick="s5()">5<tton></td><td><button onclick="s6()">6<tton></td><td><button onclick="s11()">*<tton></td>
</tr>
<tr>
<td><button onclick="s1()">1<tton></td><td><button onclick="s2()">2<tton></td><td><button onclick="s3()">3<tton></td><td><button onclick="s12()">-<tton></td>
</tr>
<tr>
<td><button onclick="s0()">0<tton></td><td><button onclick="s13()">.<tton></td><td><button onclick="s14()">=<tton></td><td><button onclick="s15()">+<tton></td>
</tr>
</table>
<script>
var num;
var i;
function Ac(){
result.value="";
}
function s0(){
result.value=result.value+0;
}
function s1(){
result.value=result.value+1;
}
function s2(){
result.value=result.value+2;
}
function s3(){
result.value=result.value+3;
}
function s4(){
result.value=result.value+4;
}
function s5(){
result.value=result.value+5;
}
function s6(){
result.value=result.value+6;
}
function s7(){
result.value=result.value+7;
}
function s8(){
result.value=result.value+8;
}
function s9(){
result.value=result.value+9;
}
function s10(){
num=result.value;
result.value="";
i=4;
}
function s11(){
num=result.value;
result.value="";
i=3;
}
function s12(){
num=parseFloat(result.value);
result.value="";
i=2;
}
function s13(){
if(result.value.indexOf(".")==-1)
result.value=result.value+".";
}
function s14(){
if(i==1){
result.value=parseFloat(result.value)+num;}
if(i==2){
result.value=num-parseFloat(result.value);}
if(i==3){
result.value=result.value*num;
}
if(i==4){
result.value=num/result.value;
}
}
function s15(){
num=parseFloat(result.value);
result.value="";
i=1;

}
</script>